package com.hup.joystick.constant;

import java.awt.event.InputEvent;

/**
 * @author hugan
 * @date 2020/10/25
 */
public class FunctionConstant {

    public enum FunctionType {
        NONE(0, "无"),
        QUICK_MENU(4, "快捷菜单"),
        MOUSE_MOVE(1, "移动鼠标"),
        MOUSE_BUTTON(2, "鼠标按键"),
        KEYBOARD(3, "键盘按键");

        public final int index;
        public final String desc;

        FunctionType(int index, String desc) {
            this.index = index;
            this.desc = desc;
        }
    }

    /**
     * 移动鼠标的控制类型
     */
    public enum MouseMoveType {
        ARROW(0, "方向键"),
        STICK_LEFT(1, "左摇杆"),
        STICK_RIGHT(2, "右摇杆");

        public final int index;
        public final String desc;

        MouseMoveType(int index, String desc) {
            this.index = index;
            this.desc = desc;
        }
    }

    /**
     * 鼠标按键
     */
    public enum MouseButton {
        LEFT(InputEvent.BUTTON1_DOWN_MASK, "左键"),
        RIGHT(InputEvent.BUTTON3_DOWN_MASK, "右键"),
        MIDDLE(InputEvent.BUTTON2_DOWN_MASK, "中键"),
        /**
         * 这两个键,不同鼠标可能不一样
         */
        BACKWARD(InputEvent.getMaskForButton(4), "后退"),
        FORWARD(InputEvent.getMaskForButton(5), "前进");

        public final int button;
        public final String desc;

        MouseButton(int button, String desc) {
            this.button = button;
            this.desc = desc;
            //查询是否支持额外的鼠标按键
            //boolean extraMouseButtonsEnabled = Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled();
            //log.info("extraMouseButtonsEnabled={}", extraMouseButtonsEnabled);
            //int numberOfButtons = MouseInfo.getNumberOfButtons();
            //for (int i = 1; i <= numberOfButtons; i++) {
            //    int mask = InputEvent.getMaskForButton(i);
            //
            //}
        }
    }

    /**
     * 快捷菜单的功能类型
     */
    public enum QuickMenuFunctionType {
        NONE("无"),
        /**
         * 命令功能
         */
        CMD("功能命令"),
        /**
         * 键盘按键功能
         */
        KEYBOARD("键盘按键"),
        ;

        public final String desc;

        QuickMenuFunctionType(String desc) {
            this.desc = desc;
        }
    }

}
